<table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
      <tr align=center>
        <td class="title" width="100%">Customers VIP: <a href="./?act=customers_mb_m"><font class="V10pt" color="#ffffff">Nh&#7853;p M&#7899;i</font></a>
	</td>
      </tr>
    </table>
<?
	switch ($_GET['action'])
	{
		case 'del' :
			$id = $_GET['id'];
			$sql = "delete from customers_mb where customers_id='".$id."'";
			$result = mysql_query($sql,$con);
			echo mysql_error();
			if ($result) echo "<p align=center class='err'>&#272;ã xóa thành công</p>";
				else echo "<p align=center class='err'>Không th&#7875; xóa d&#7919; li&#7879;u</p>";
			break;
	}
?>

<?
	if (isset($_POST['ButDel'])) {
		$cnt=0;
		foreach ($_POST['chk'] as $id)
		{
			@$result = mysql_query("delete from customers_mb where customers_id='".$id."'",$con);
			if ($result) $cnt++;
		}
		echo "<p align=center class='err'>&#272;ã xóa ".$cnt." ph&#7847;n t&#7917;</p>";
	}
	
?>

<form action="index.php" method="POST" name="frmList">
<input type=hidden name="page" value="<? echo $page; ?>">
<?
function taotrang($sql,$link,$nitem,$itemcurrent)
{	global $con;
	$ret="";
	$result = mysql_query($sql, $con) or die('Error' . mysql_error());
	$value = mysql_fetch_array($result);
	$plus = (($value['cnt'] % $nitem)>0);
	for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
	{
		if ($i+1<>$itemcurrent) $ret .= "<a href=\"".$link.($i+1)."\" class=\"lslink\">".($i+1)."</a> ";
		else $ret .= ($i+1)." ";
	}
	return $ret;
}
	$pageindex=taotrang("select count(*) from customers_mb","./?act=customer_mb"."&page=",20,$page);
?>

<table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
<? if ($_REQUEST['code']==1) echo '<tr><td colspan="2" align="center" class="err">&#272;ã c&#7853;p nh&#7853;t thành công</td></tr>'; ?>
  <tr>
  <td class="smallfont" colspan="11">Trang : <? echo $pageindex; ?></td>
  </tr>
</table>
  
<table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
  <tr>
    <td width="10" align=center class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
    <td width="10" colspan="2" class="title">&nbsp;</td>
    <td align="center" class="title"><b>ID</b></td>
    <td align="center" nowrap class="title"><b>Name</b></td>
	<td align="center" nowrap class="title"><b>Ti&#234;u &#273;&#7873;</b></td>
	 <td align="center" nowrap class="title"><b>t&#236;nh tr&#7841;ng</b></td>  
    <td align="center" nowrap class="title"><b>Email</b></td>   
    <td align="center" nowrap class="title"><b>Date</b></td>    
  </tr>
  
  <?php
			$page = $_GET["page"];
        	$sql="select * from customers_mb order by customers_date_added desc";
        	$result=mysql_query($sql,$con);
        	$i=0;
        	@mysql_data_seek($result,($page-1)*20);
           	while(($row=mysql_fetch_array($result)) && $i<20)
			{
			$i++;
			if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
			if($row['customers_status']==1) $status= "<b>&#272;&#227; duy&#7879;t<b>";
			else $status= "Ch&#432;a duy&#7879;t";
  ?>
  
  <tr>
    <td bgcolor="<? echo $color; ?>" class="smallfont">
    <p align="center"><input type="checkbox" name="chk[]" value="<? echo $row['customers_id']; ?>"></td>
    <td bgcolor="<? echo $color; ?>" class="smallfont">
    <p align="center">
    <a href="./?act=customers_mb_m&id=<? echo $row['customers_id']; ?>&page=<? echo $page?>">Edit</a></td>
    <td bgcolor="<? echo $color; ?>" class="smallfont">
    <p align="center">
    <a onclick="return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" href="./?act=customers_mb&action=del&id=<? echo $row['customers_id']; ?>">Delete</a></td>
    <td bgcolor="<? echo $color; ?>"  align="left" class="smallfont"><? echo $row['customers_id']; ?>&nbsp; </td>
    <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['customers_name']; ?>&nbsp;</td>   
	  <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['customers_address']; ?>&nbsp;</td>
	<td class="smallfont" align="center"><?=$status?>&nbsp;</td>    
    <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['customers_email']; ?>&nbsp;</td>
    <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['customers_date_added']; ?>&nbsp;</td>    
  </tr>
  <?
              	}
  ?>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1">
<tr>
	<td width="90">
		<input type="submit" value="Xóa Ch&#7885;n" name="ButDel" onclick="return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" class="button">
		<input type="hidden" name="act" value="customers_mb">
	</td>
		
	<td>
		
	</td>
</tr>
</table>


</form>
<script language="JavaScript">
function chkallClick(o) {
  	var form = document.frmList;
	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
			form.elements[i].checked = document.frmList.chkall.checked;
		}
	}
}
</script>